package com.adv.ems.controller.client;

import com.adv.ems.constants.SystemConst;
import com.adv.ems.model.dto.APIRequest;
import com.adv.ems.model.dto.APIResponse;
import com.adv.ems.model.param.WarningDealParam;
import com.adv.ems.model.param.WarningListParam;
import com.adv.ems.model.vo.WarningListVO;
import com.adv.ems.service.WarningService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

@RestController
@RequestMapping("/ems/client/warning")
public class WarningController {
    @Resource
    WarningService warningService;

    @PostMapping("/list")
    public APIResponse<WarningListVO> list(@RequestHeader(name = SystemConst.Header.ACCEPT_LANGUAGE, defaultValue = SystemConst.Header.ZH_CN) String acceptLanguage,
                                           @RequestBody APIRequest<WarningListParam> request) {
        return APIResponse.<WarningListVO>build().content(warningService.list(request.getContent(), acceptLanguage));
    }

    @PostMapping("/deal")
    public APIResponse<Boolean> deal(@RequestHeader(name = SystemConst.Header.ACCEPT_LANGUAGE, defaultValue = SystemConst.Header.ZH_CN) String acceptLanguage,
                                           @RequestBody APIRequest<WarningDealParam> request) {
        return APIResponse.<Boolean>build().content(warningService.deal(request.getContent(), acceptLanguage));
    }
}
